package com.tiantian.quanminxiu.activity;

import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.tiantian.quanminxiu.R;
import com.tiantian.quanminxiu.utils.ActivityBase;
import com.tiantian.quanminxiu.utils.UserData;

/**
 * Created by admin on 2016/9/20.
 */
public class Activity_Signature extends ActivityBase{

    public static String sign = "";
    private EditText et_changesign_info;
    private TextView tv_changesign_num;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_signature);
        Init();

        InitView();
        initAction();
    }

    @Override
    public void InitView() {
        et_changesign_info = (EditText) findViewById(R.id.et_changesign_info);
        tv_changesign_num = (TextView) findViewById(R.id.tv_changesign_num);
    }

    @Override
    public void PageInit() {

    }

    private void initAction() {
        // TODO Auto-generated method stub
        if (!TextUtils.isEmpty(UserData.Base.Signature)&&!"null".equals(UserData.Base.Signature)) {
            et_changesign_info.setText(UserData.Base.Signature);
            tv_changesign_num.setText(UserData.Base.Signature.length() + "/20");
        }
        mHeader.txtHeader_Enter.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                sign = et_changesign_info.getText().toString();
                Intent intent = new Intent();
                intent.putExtra("signature",et_changesign_info.getText().toString());
                setResult(RESULT_OK, intent);
                finish();
            }
        });
        et_changesign_info.addTextChangedListener(new TextWatcher() {

            @Override
            public void onTextChanged(CharSequence s, int start, int before,
                                      int count) {
                // TODO Auto-generated method stub

            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count,
                                          int after) {
                // TODO Auto-generated method stub

            }

            @Override
            public void afterTextChanged(Editable s) {
                // TODO Auto-generated method stub
                tv_changesign_num.setText(s.length() + "/20");
            }
        });
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
    }
}

